package com.negocio.entidades;
import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@NamedQuery(name="Usuario.findUsuByEmail", query="select u from Usuario u where u.email = :email")
public class Usuario implements Serializable {
	public static final String FIND_BY_EMAIL = "Usuario.findUsuByEmail";
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;
	
	@Column(nullable=false, unique=true)
	private String matricula;
	
	@Enumerated(EnumType.STRING)
	@Column(nullable=false)
	private PerfilUsuario perfil;
	
	@Column(nullable=false)
	private String nome;
	
	@Column(nullable=false, unique=true)
	private String login;
	
	@Column(nullable=false)
	private String senha;
	
	@Column(nullable=true)
	private String curso;
	
	@Column(nullable=false)
	private String email;
	
	@Column(nullable=false)
	private boolean status;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable=false)
	private Date dtCad;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getMatricula() {
		return matricula;
	}

	public void setMatricula(String matricula) {
		this.matricula = matricula;
	}

	public PerfilUsuario getPerfil() {
		return perfil;
	}

	public void setPerfil(PerfilUsuario perfil) {
		this.perfil = perfil;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getSenha() {
		return senha;
	}

	public void setSenha(String senha) {
		this.senha = senha;
	}

	public String getCurso() {
		return curso;
	}

	public void setCurso(String curso) {
		this.curso = curso;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}

	public Date getDtCad() {
		return dtCad;
	}

	public void setDtCad(Date dtCad) {
		this.dtCad = dtCad;
	}
	
	@Override
	public boolean equals(Object u){
		if(u instanceof Usuario){
			final Usuario uOutro = (Usuario) u;
			return (uOutro.getNome().equals(this.nome) && uOutro.getDtCad().equals(this.dtCad));
		}
		return true;
	}
	
	
	@Override
	public int hashCode(){
		return this.hashCode();
	}
	
	
	
}
